package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("business/jxsh")
public @caption("经销商") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("tb_jxsh") class TbJxsh implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
		
	
		
	private @caption("编号") @column("tbj_id")    @primary  @notnull  @note("  ") Long tbjId;// 主键 非空     
			
 			
 			
 		
	
		
	private @caption("品牌") @column("tbj_brand")      @relate("$tbjBrand") @RelateClass(Merchant.class)  @note("  ") Long tbjBrand;//     
			
 	private transient Merchant $tbjBrand;//关联对象[品牌信息]
 			
 			
 			
 		
	
		
	private @caption("经销商名称") @column("tbj_name")      @note("  ") String tbjName;//     
			
 			
 			
 		
	
		
	private @caption("电话") @column("tbj_phone")      @note("  ") String tbjPhone;//     
			
 			
 			
 		
	
		
	private @caption("总收益") @column("tbj_profit")   @hidden    @note("  ") Double tbjProfit;//     
			
 			
 			
 		
	
		
	private @caption("所在位置") @column("tbj_location")      @relate("$tbjLocation") @RelateClass(Region.class)  @note("  ") Long tbjLocation;//     
			
 	private transient Region $tbjLocation;//关联对象[省市地区]
 			
 			
 			
 		
	
		
	private @caption("添加时间") @column("tbj_add_time")      @note("  ") Date tbjAddTime;//     
			
 			
 			
 		
	
		
	private @caption("状态") @column("tbj_status")      @note(" 0:无效 1:有效  ") Short tbjStatus;// 0:无效 1:有效     
			
 			
 			
 		
	
	 
	//默认构造函数
	public TbJxsh(){ 
	
	}
	
	//主键构造函数
	public TbJxsh(Long id){
		this.tbjId = id;
	}
	
	/**所有字段构造函数 
	 TbJxsh(
	 	Utils.getLong("brand")//品牌
	 	,Utils.getString("name")//经销商名称
	 	,Utils.getString("phone")//电话
	 	,Utils.getDouble("profit")//总收益
	 	,Utils.getLong("location")//所在位置
	 	,Utils.getDate("addTime")//添加时间
	 	,Utils.getShort("status")//状态
	 )
	**/
	public TbJxsh(Long tbjBrand,String tbjName,String tbjPhone,Double tbjProfit,Long tbjLocation,Date tbjAddTime,Short tbjStatus){
		
			
			
		this.tbjBrand=tbjBrand;
		
			
		this.tbjName=tbjName;
		
			
		this.tbjPhone=tbjPhone;
		
			
		this.tbjProfit=tbjProfit;
		
			
		this.tbjLocation=tbjLocation;
		
			
		this.tbjAddTime=tbjAddTime;
		
			
		this.tbjStatus=tbjStatus;
		
	}
	
	//设置非空字段
	public TbJxsh setNotNull(){
		
			
			
			
			
			
			
			
			
		return this;
	}
	
	
		
	/** 编号 [非空]       **/
	public TbJxsh tbjId(Long tbjId){
		this.tbjId = tbjId;
		this.setSeted(F.tbjId);
		return this;
	}
	
		
	/** 品牌  [Merchant]      **/
	public TbJxsh tbjBrand(Long tbjBrand){
		this.tbjBrand = tbjBrand;
		this.setSeted(F.tbjBrand);
		return this;
	}
	
		
	/** 经销商名称        **/
	public TbJxsh tbjName(String tbjName){
		this.tbjName = tbjName;
		this.setSeted(F.tbjName);
		return this;
	}
	
		
	/** 电话        **/
	public TbJxsh tbjPhone(String tbjPhone){
		this.tbjPhone = tbjPhone;
		this.setSeted(F.tbjPhone);
		return this;
	}
	
		
	/** 总收益        **/
	public TbJxsh tbjProfit(Double tbjProfit){
		this.tbjProfit = tbjProfit;
		this.setSeted(F.tbjProfit);
		return this;
	}
	
		
	/** 所在位置  [Region]      **/
	public TbJxsh tbjLocation(Long tbjLocation){
		this.tbjLocation = tbjLocation;
		this.setSeted(F.tbjLocation);
		return this;
	}
	
		
	/** 添加时间        **/
	public TbJxsh tbjAddTime(Date tbjAddTime){
		this.tbjAddTime = tbjAddTime;
		this.setSeted(F.tbjAddTime);
		return this;
	}
	
		
	/** 状态    0:无效 1:有效     **/
	public TbJxsh tbjStatus(Short tbjStatus){
		this.tbjStatus = tbjStatus;
		this.setSeted(F.tbjStatus);
		return this;
	}
	
	
	
	/**
	* 克隆对象
	**/
	public TbJxsh clone(){
		TbJxsh clone = new TbJxsh();
		
			
			
		clone.tbjBrand=this.tbjBrand;
		
			
		clone.tbjName=this.tbjName;
		
			
		clone.tbjPhone=this.tbjPhone;
		
			
		clone.tbjProfit=this.tbjProfit;
		
			
		clone.tbjLocation=this.tbjLocation;
		
			
		clone.tbjAddTime=this.tbjAddTime;
		
			
		clone.tbjStatus=this.tbjStatus;
		
		return clone;
	}
	
	
	
	
	
	/**
	 * 根据ID取经销商
	 * @param id
	 * @return
	 */
	public static @api TbJxsh get(Long id){		
		return getTbJxshById(id);
	}
	
	
	/**
	 * 设置ID
	 * @param id
	 * @return
	 */
	public void setId(Long id){		
		this.tbjId = id;
	}
	
	
	/**
	 * 获取所有经销商
	 * @return
	 */
	public static @api List<TbJxsh> list(Map params,Integer size){
		return getTbJxshList(params,size);
	}
	/**
	 * 获取经销商分页
	 * @return
	 */
	public static @api Page<TbJxsh> page(Integer page,Integer size,Map params){
		return getTbJxshPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取经销商
	 * @param params
	 * @return
	 */
	public static @api TbJxsh Get(Map params){
		return getTbJxsh(params);
	}
	/**
	 * 获取经销商数
	 * @return
	 */
	public static @api Long count(Map params){
		return getTbJxshCount(params);
	}
	/**
	 * 获取经销商数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getTbJxshEval(eval,params);
	}
	
	
	/**
	 * 获取经销商图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getTbJxshStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取经销商图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getTbJxshStats(params,sumKey,groupKey,dateType);
	}
	
	
	/**
	 * 根据ID取经销商
	 * @param id
	 * @return
	 */
	public static @api TbJxsh getTbJxshById(Long id){		
		return getTbJxshDao().getTbJxshById(id);
	}
	
	
	/**
	 * 获取id
	 * @return
	 */
	public Long getId(){
		return this.tbjId;
	}
	
	
	
	/**
	 * 根据ID取经销商的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			
			return null;
			
		}
		String value = null;
		
		value = Cache.getValue(TbJxsh.class, id);
				
		if(value==null){
			TbJxsh tbJxsh = get(id);
			if(tbJxsh!=null){
				String strValue = tbJxsh.getTbjName$();
				
				if(!"TbjName".equals("TbjName"))
					strValue+="("+tbJxsh.getTbjName$()+")";
				
				
				Cache.setValue(TbJxsh.class, id ,strValue);
				
				value = strValue;
			}else{
				
				Cache.setValue(TbJxsh.class, id ,"{"+id+"}",30);
				
				value = "{"+id+"}";
			}
		}
		
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getTbjName$();
		
		if(!"TbjName".equals("TbjName"))
			keyValue+="("+this.getTbjName$()+")";
		
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询经销商对象
	 * @return
	 */
	public static @api TbJxsh find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("tbjId", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			
			strDefinex+=" or tbj_name = '"+key.replaceAll("'", "''")+"'";
			
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return TbJxsh.getTbJxsh(params);
	}
	
	
	/**
	 * 根据关键字查询经销商
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","tbj_id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("tbjId", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				
				strDefinex+=" or tbj_name like '%"+strTerm.replaceAll("'", "''")+"%'";
				
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		
		
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<TbJxsh> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(TbJxsh tbJxsh:list){
			Map map = new HashMap();
			map.put("key",tbJxsh.getTbjId().toString());
			map.put("value", Utils.js(tbJxsh.getKeyValue()));
			if(bObject==true)
				map.put("object",tbJxsh);
			result.add(map);
		}
		
		
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有经销商
	 * @return
	 */
	public static @api List<TbJxsh> getTbJxshList(Map params,Integer size){
		return getTbJxshDao().getTbJxshList(params,0,size);
	}
	
	/**
	 * 获取经销商分页
	 * @return
	 */
	public static @api Page<TbJxsh> getTbJxshPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getTbJxshDao().getTbJxshPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取经销商
	 * @param params
	 * @return
	 */
	public static @api TbJxsh getTbJxsh(Map params){
		return getTbJxshDao().getTbJxsh(params);
	}
	
	/**
	 * 保存一个经销商
	 * @param tbJxsh
	 * @return
	 */
	public static @api TbJxsh saveTbJxsh(TbJxsh tbJxsh){
		return getTbJxshDao().saveTbJxsh(tbJxsh);
	}
	
	/**
	 * 根据条件更新经销商
	 * @param values
	 * @param params
	 */
	public static @api int updateTbJxshByConfirm(Map values, Map params){
		return getTbJxshDao().updateTbJxshByConfirm(values,params);
	}
	
	/**
	 * 修改一个经销商
	 * @param tbJxsh
	 * @return
	 */
	public static @api int updateTbJxsh(TbJxsh tbJxsh){
		return getTbJxshDao().updateTbJxsh(tbJxsh);
	}
	
	/**
	 * 更新经销商非空字段
	 * @param tbJxsh
	 */
	public static @api int updateTbJxsh$NotNull(TbJxsh tbJxsh){
		return getTbJxshDao().updateTbJxsh$NotNull(tbJxsh);
	}
	
	/**
	 * 获取经销商数
	 * @return
	 */
	public static @api Long getTbJxshCount(Map params){
		return getTbJxshDao().getTbJxshCount(params);
	}
		
		
	/**
	 * 获取经销商自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getTbJxshEval(String eval,Map params){
		return getTbJxshDao().getTbJxshEval(eval,params);
	}
	
	
	/**
	 * 获取经销商图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getTbJxshStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getTbJxshDao().getTbJxshStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = TbJxsh.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(TbJxsh.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateTbJxsh(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getTbJxshDao().updateTbJxshByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteTbJxsh(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getTbJxshDao().deleteTbJxshByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		
		getTbJxshDao().removeTbJxshById(id);
		
	}
	
	
	/**
	 * 保存经销商对象
	 * @param params
	 * @return
	 */
	public TbJxsh save(){
		if(this.getTbjId()!=null)
			getTbJxshDao().updateTbJxsh(this);
		else
			return getTbJxshDao().saveTbJxsh(this);
		return this;
	}
	
	
	/**
	 * 更新经销商对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getTbJxshDao().updateTbJxsh$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
		
		if(Utils.equals(Utils.config("logic_delete"),"true"))
			getTbJxshDao().removeTbJxshById(this.getTbjId());
		else
		
			getTbJxshDao().deleteTbJxshById(this.getTbjId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getTbJxshDao().executeTransaction(function);
	}

	
	
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getTbjId(){
		
		if(this.tbjId!=null){
			return this.tbjId;
		}
		
		return this.tbjId;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getTbjId$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbjId());
	 
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setTbjId$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjId=null;
			return;
		}
	
	
	 	this.tbjId=Utils.parseLong(strValue);
	 
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setTbjId(Long tbjId){
		this.tbjId = tbjId;
		
		this.setSeted(F.tbjId);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************品牌**********************************/	
	/**
	* 品牌  [Merchant]     
	**/
	public Long getTbjBrand(){
		
		if(this.tbjBrand!=null){
			return this.tbjBrand;
		}
		
		return this.tbjBrand;
	}
	/**
	* 获取品牌格式化(toString)
	**/
	public String getTbjBrand$(){
		String strValue="";
	
	
		 
		if(this.getTbjBrand()!=null){
			
				strValue+=Utils.string(Merchant.getKeyValue(this.getTbjBrand()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据品牌反格式化
	**/
	public void setTbjBrand$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjBrand=null;
			return;
		}
	
	
		 
		Merchant item = Merchant.find(strValue);
		if(item!=null){
			
			this.tbjBrand = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 品牌  [Merchant]     
	**/
	public void setTbjBrand(Long tbjBrand){
		this.tbjBrand = tbjBrand;
		
		this.setSeted(F.tbjBrand);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[品牌信息]
	**/	 			
 	public Merchant get$tbjBrand(){
 		if(this.$tbjBrand!=null)
 			return this.$tbjBrand;
 		com.distribute.framework.model.Merchant merchant = null;
		if(this.getTbjBrand()!=null){
		
 			merchant = Merchant.get(this.getTbjBrand());
 		
 		}
 		return merchant;
	}
	
 	
	
	
	/*******************************经销商名称**********************************/	
	/**
	* 经销商名称       
	**/
	public String getTbjName(){
		
		if(this.tbjName!=null){
			return this.tbjName;
		}
		
		return this.tbjName;
	}
	/**
	* 获取经销商名称格式化(toString)
	**/
	public String getTbjName$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbjName());
	 
	 	 return strValue;
	}
	/**
	* 根据经销商名称反格式化
	**/
	public void setTbjName$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjName=null;
			return;
		}
	
	
	 	this.tbjName=strValue;
	 
	}
	
	/**
	* 经销商名称       
	**/
	public void setTbjName(String tbjName){
		this.tbjName = tbjName;
		
		this.setSeted(F.tbjName);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************电话**********************************/	
	/**
	* 电话       
	**/
	public String getTbjPhone(){
		
		if(this.tbjPhone!=null){
			return this.tbjPhone;
		}
		
		return this.tbjPhone;
	}
	/**
	* 获取电话格式化(toString)
	**/
	public String getTbjPhone$(){
		String strValue="";
	
	
		 strValue=Utils.string(this.getTbjPhone());
	 
	 	 return strValue;
	}
	/**
	* 根据电话反格式化
	**/
	public void setTbjPhone$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjPhone=null;
			return;
		}
	
	
	 	this.tbjPhone=strValue;
	 
	}
	
	/**
	* 电话       
	**/
	public void setTbjPhone(String tbjPhone){
		this.tbjPhone = tbjPhone;
		
		this.setSeted(F.tbjPhone);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************总收益**********************************/	
	/**
	* 总收益       
	**/
	public Double getTbjProfit(){
		
		if(this.tbjProfit!=null){
			return this.tbjProfit;
		}
		
		return this.tbjProfit;
	}
	/**
	* 获取总收益格式化(toString)
	**/
	public String getTbjProfit$(){
		String strValue="";
	
	
			
		 strValue=Utils.string(this.getTbjProfit());	
			
	 
	 	 return strValue;
	}
	/**
	* 根据总收益反格式化
	**/
	public void setTbjProfit$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjProfit=null;
			return;
		}
	
	
	 	this.tbjProfit=Utils.parseDouble(strValue);
	 
	}
	
	/**
	* 总收益       
	**/
	public void setTbjProfit(Double tbjProfit){
		this.tbjProfit = tbjProfit;
		
		this.setSeted(F.tbjProfit);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************所在位置**********************************/	
	/**
	* 所在位置  [Region]     
	**/
	public Long getTbjLocation(){
		
		if(this.tbjLocation!=null){
			return this.tbjLocation;
		}
		
		return this.tbjLocation;
	}
	/**
	* 获取所在位置格式化(toString)
	**/
	public String getTbjLocation$(){
		String strValue="";
	
	
		 
		if(this.getTbjLocation()!=null){
			
				strValue+=Utils.string(Region.getKeyValue(this.getTbjLocation()));
			
		}			
		 
	 
	 	 return strValue;
	}
	/**
	* 根据所在位置反格式化
	**/
	public void setTbjLocation$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjLocation=null;
			return;
		}
	
	
		 
		Region item = Region.find(strValue);
		if(item!=null){
			
			this.tbjLocation = Utils.parseLong(item.getId());
			
		}
		 
	 
	}
	
	/**
	* 所在位置  [Region]     
	**/
	public void setTbjLocation(Long tbjLocation){
		this.tbjLocation = tbjLocation;
		
		this.setSeted(F.tbjLocation);
		
	}
	
	
		 
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 		
	/**
	* 获取关联对象[省市地区]
	**/	 			
 	public Region get$tbjLocation(){
 		if(this.$tbjLocation!=null)
 			return this.$tbjLocation;
 		com.distribute.framework.model.Region region = null;
		if(this.getTbjLocation()!=null){
		
 			region = Region.get(this.getTbjLocation());
 		
 		}
 		return region;
	}
	
 	
	
	
	/*******************************添加时间**********************************/	
	/**
	* 添加时间       
	**/
	public Date getTbjAddTime(){
		
		if(this.tbjAddTime!=null){
			return this.tbjAddTime;
		}
		
		return this.tbjAddTime;
	}
	/**
	* 获取添加时间格式化(toString)
	**/
	public String getTbjAddTime$(){
		String strValue="";
	
	
	 	
		 strValue=Utils.string(Utils.date(this.getTbjAddTime(),"yyyy-MM-dd HH:mm:ss"));
		
	 
	 	 return strValue;
	}
	/**
	* 根据添加时间反格式化
	**/
	public void setTbjAddTime$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjAddTime=null;
			return;
		}
	
	
	 	this.tbjAddTime=Utils.date(strValue,"yyyy-MM-dd HH:mm:ss");
	 
	}
	
	/**
	* 添加时间       
	**/
	public void setTbjAddTime(Date tbjAddTime){
		this.tbjAddTime = tbjAddTime;
		
		this.setSeted(F.tbjAddTime);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	/*******************************状态**********************************/	
	/**
	* 状态    0:无效 1:有效    
	**/
	public Short getTbjStatus(){
		
		if(this.tbjStatus!=null){
			return this.tbjStatus;
		}
		
		return this.tbjStatus;
	}
	/**
	* 获取状态格式化(toString)
	**/
	public String getTbjStatus$(){
		String strValue="";
	
	
		
			
		 if(Utils.equals(Utils.string(this.getTbjStatus()),"0"))
			strValue=Utils.string("无效");		 
			
		 if(Utils.equals(Utils.string(this.getTbjStatus()),"1"))
			strValue=Utils.string("有效");		 
			
		
	 
	 	 return strValue;
	}
	/**
	* 根据状态反格式化
	**/
	public void setTbjStatus$(String strValue){
		if(Utils.empty(strValue)){
			this.tbjStatus=null;
			return;
		}
	
	
		
			
		 if(Utils.equals(strValue,"无效"))
		 	this.tbjStatus=Utils.parseShort("0");
			
		 if(Utils.equals(strValue,"有效"))
		 	this.tbjStatus=Utils.parseShort("1");
			
		
	 
	}
	
	/**
	* 状态    0:无效 1:有效    
	**/
	public void setTbjStatus(Short tbjStatus){
		this.tbjStatus = tbjStatus;
		
		this.setSeted(F.tbjStatus);
		
	}
	
	
	
	
	
	
	
	
	
	
 	
 	
	
	
	
	
	
 	
 	
 	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/	
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(TbJxsh.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(TbJxsh.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(TbJxsh.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(TbJxsh.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(TbJxsh.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${TbJxsh.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${TbJxsh.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return TbJxsh.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(TbJxsh.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${TbJxsh.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${TbJxsh.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return TbJxsh.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(TbJxsh.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		
		
			
		
		/** 编号 [非空]       **/
		public M tbjId(Object tbjId){if(proxy)return proxy().tbjId(tbjId);  this.put("tbjId", tbjId);return this;};
	 	/** and tbj_id is null */
 		public M tbjIdNull(){if(proxy)return proxy().tbjIdNull();if(this.get("tbjIdNot")==null)this.put("tbjIdNot", "");this.put("tbjId", null);return this;};
 		/** not .... */
 		public M tbjIdNot(){if(proxy)return proxy().tbjIdNot();this.put("tbjIdNot", "not");return this;};
 		public M tbjIdNotNull(){if(proxy)return proxy().tbjIdNotNull();this.put("tbjIdNot", "not");this.put("tbjId", null);return this;};
 		public M tbjIdNot(Object tbjId){if(proxy)return proxy().tbjIdNot(tbjId);this.put("tbjIdNot", "not");this.put("tbjId", tbjId);return this;};
	 		
		/** and tbj_id <= ? */
		public M tbjIdMin(Object min){if(proxy)return proxy().tbjIdMin(min);this.put("tbjIdMin", min);return this;};
		/** and tbj_id >= ? */
		public M tbjIdMax(Object max){if(proxy)return proxy().tbjIdMax(max);this.put("tbjIdMax", max);return this;};
			
			
		public M tbjIdIn(String ids){
			if(proxy)return proxy().tbjIdIn(ids);  this.put("tbjIdIn", ids);return this;
		};	
 			
		
			
	 	
			
		public M tbjBrand$on(Merchant.M value){if(proxy)return proxy().tbjBrand$on(value);this.put("TbjBrand", value);value.put("on", "tbj_brand");return this;};
 				
 			
		
		/** 品牌  [Merchant]      **/
		public M tbjBrand(Object tbjBrand){if(proxy)return proxy().tbjBrand(tbjBrand);  this.put("tbjBrand", tbjBrand);return this;};
	 	/** and tbj_brand is null */
 		public M tbjBrandNull(){if(proxy)return proxy().tbjBrandNull();if(this.get("tbjBrandNot")==null)this.put("tbjBrandNot", "");this.put("tbjBrand", null);return this;};
 		/** not .... */
 		public M tbjBrandNot(){if(proxy)return proxy().tbjBrandNot();this.put("tbjBrandNot", "not");return this;};
 		public M tbjBrandNotNull(){if(proxy)return proxy().tbjBrandNotNull();this.put("tbjBrandNot", "not");this.put("tbjBrand", null);return this;};
 		public M tbjBrandNot(Object tbjBrand){if(proxy)return proxy().tbjBrandNot(tbjBrand);this.put("tbjBrandNot", "not");this.put("tbjBrand", tbjBrand);return this;};
	 		
			
		public M tbjBrandIn(String ids){
			if(proxy)return proxy().tbjBrandIn(ids);  this.put("tbjBrandIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 经销商名称        **/
		public M tbjName(Object tbjName){if(proxy)return proxy().tbjName(tbjName);  this.put("tbjName", tbjName);return this;};
	 	/** and tbj_name is null */
 		public M tbjNameNull(){if(proxy)return proxy().tbjNameNull();if(this.get("tbjNameNot")==null)this.put("tbjNameNot", "");this.put("tbjName", null);return this;};
 		/** not .... */
 		public M tbjNameNot(){if(proxy)return proxy().tbjNameNot();this.put("tbjNameNot", "not");return this;};
 		public M tbjNameNotNull(){if(proxy)return proxy().tbjNameNotNull();this.put("tbjNameNot", "not");this.put("tbjName", null);return this;};
 		public M tbjNameNot(Object tbjName){if(proxy)return proxy().tbjNameNot(tbjName);this.put("tbjNameNot", "not");this.put("tbjName", tbjName);return this;};
	 		
			
		
			
	 	
			
		
		/** 电话        **/
		public M tbjPhone(Object tbjPhone){if(proxy)return proxy().tbjPhone(tbjPhone);  this.put("tbjPhone", tbjPhone);return this;};
	 	/** and tbj_phone is null */
 		public M tbjPhoneNull(){if(proxy)return proxy().tbjPhoneNull();if(this.get("tbjPhoneNot")==null)this.put("tbjPhoneNot", "");this.put("tbjPhone", null);return this;};
 		/** not .... */
 		public M tbjPhoneNot(){if(proxy)return proxy().tbjPhoneNot();this.put("tbjPhoneNot", "not");return this;};
 		public M tbjPhoneNotNull(){if(proxy)return proxy().tbjPhoneNotNull();this.put("tbjPhoneNot", "not");this.put("tbjPhone", null);return this;};
 		public M tbjPhoneNot(Object tbjPhone){if(proxy)return proxy().tbjPhoneNot(tbjPhone);this.put("tbjPhoneNot", "not");this.put("tbjPhone", tbjPhone);return this;};
	 		
			
		
			
	 	
			
		
		/** 总收益        **/
		public M tbjProfit(Object tbjProfit){if(proxy)return proxy().tbjProfit(tbjProfit);  this.put("tbjProfit", tbjProfit);return this;};
	 	/** and tbj_profit is null */
 		public M tbjProfitNull(){if(proxy)return proxy().tbjProfitNull();if(this.get("tbjProfitNot")==null)this.put("tbjProfitNot", "");this.put("tbjProfit", null);return this;};
 		/** not .... */
 		public M tbjProfitNot(){if(proxy)return proxy().tbjProfitNot();this.put("tbjProfitNot", "not");return this;};
 		public M tbjProfitNotNull(){if(proxy)return proxy().tbjProfitNotNull();this.put("tbjProfitNot", "not");this.put("tbjProfit", null);return this;};
 		public M tbjProfitNot(Object tbjProfit){if(proxy)return proxy().tbjProfitNot(tbjProfit);this.put("tbjProfitNot", "not");this.put("tbjProfit", tbjProfit);return this;};
	 		
		/** and tbj_profit <= ? */
		public M tbjProfitMin(Object min){if(proxy)return proxy().tbjProfitMin(min);this.put("tbjProfitMin", min);return this;};
		/** and tbj_profit >= ? */
		public M tbjProfitMax(Object max){if(proxy)return proxy().tbjProfitMax(max);this.put("tbjProfitMax", max);return this;};
			
			
		
			
	 	
			
		public M tbjLocation$on(Region.M value){if(proxy)return proxy().tbjLocation$on(value);this.put("TbjLocation", value);value.put("on", "tbj_location");return this;};
 				
 			
		
		/** 所在位置  [Region]      **/
		public M tbjLocation(Object tbjLocation){if(proxy)return proxy().tbjLocation(tbjLocation);  this.put("tbjLocation", tbjLocation);return this;};
	 	/** and tbj_location is null */
 		public M tbjLocationNull(){if(proxy)return proxy().tbjLocationNull();if(this.get("tbjLocationNot")==null)this.put("tbjLocationNot", "");this.put("tbjLocation", null);return this;};
 		/** not .... */
 		public M tbjLocationNot(){if(proxy)return proxy().tbjLocationNot();this.put("tbjLocationNot", "not");return this;};
 		public M tbjLocationNotNull(){if(proxy)return proxy().tbjLocationNotNull();this.put("tbjLocationNot", "not");this.put("tbjLocation", null);return this;};
 		public M tbjLocationNot(Object tbjLocation){if(proxy)return proxy().tbjLocationNot(tbjLocation);this.put("tbjLocationNot", "not");this.put("tbjLocation", tbjLocation);return this;};
	 		
			
		public M tbjLocationIn(String ids){
			if(proxy)return proxy().tbjLocationIn(ids);  this.put("tbjLocationIn", ids);return this;
		};	
 			
		
			
	 	
			
		
		/** 添加时间        **/
		public M tbjAddTime(Object tbjAddTime){if(proxy)return proxy().tbjAddTime(tbjAddTime);  this.put("tbjAddTime", tbjAddTime);return this;};
	 	/** and tbj_add_time is null */
 		public M tbjAddTimeNull(){if(proxy)return proxy().tbjAddTimeNull();if(this.get("tbjAddTimeNot")==null)this.put("tbjAddTimeNot", "");this.put("tbjAddTime", null);return this;};
 		/** not .... */
 		public M tbjAddTimeNot(){if(proxy)return proxy().tbjAddTimeNot();this.put("tbjAddTimeNot", "not");return this;};
 		public M tbjAddTimeNotNull(){if(proxy)return proxy().tbjAddTimeNotNull();this.put("tbjAddTimeNot", "not");this.put("tbjAddTime", null);return this;};
 		public M tbjAddTimeNot(Object tbjAddTime){if(proxy)return proxy().tbjAddTimeNot(tbjAddTime);this.put("tbjAddTimeNot", "not");this.put("tbjAddTime", tbjAddTime);return this;};
	 		
 		/** and tbj_add_time >= ? */
 		public M tbjAddTimeStart(Object start){if(proxy)return proxy().tbjAddTimeStart(start);this.put("tbjAddTimeStart", start);return this;};			
 		/** and tbj_add_time <= ? */
 		public M tbjAddTimeEnd(Object end){if(proxy)return proxy().tbjAddTimeEnd(end);this.put("tbjAddTimeEnd", end);return this;};
			
			
		
			
	 	
			
		
		/** 状态    0:无效 1:有效     **/
		public M tbjStatus(Object tbjStatus){if(proxy)return proxy().tbjStatus(tbjStatus);  this.put("tbjStatus", tbjStatus);return this;};
	 	/** and tbj_status is null */
 		public M tbjStatusNull(){if(proxy)return proxy().tbjStatusNull();if(this.get("tbjStatusNot")==null)this.put("tbjStatusNot", "");this.put("tbjStatus", null);return this;};
 		/** not .... */
 		public M tbjStatusNot(){if(proxy)return proxy().tbjStatusNot();this.put("tbjStatusNot", "not");return this;};
 		public M tbjStatusNotNull(){if(proxy)return proxy().tbjStatusNotNull();this.put("tbjStatusNot", "not");this.put("tbjStatus", null);return this;};
 		public M tbjStatusNot(Object tbjStatus){if(proxy)return proxy().tbjStatusNot(tbjStatus);this.put("tbjStatusNot", "not");this.put("tbjStatus", tbjStatus);return this;};
	 		
			
		public M tbjStatusIn(String ids){
			if(proxy)return proxy().tbjStatusIn(ids);  this.put("tbjStatusIn", ids);return this;
		};	
 			
		
			
	 	
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	
	 	/** 获取所有经销商 **/
		public @api List<TbJxsh> list(Integer size){			
			return getTbJxshList(this,size);
		}
		/** 获取经销商分页 **/
		public @api Page<TbJxsh> page(Integer page,Integer size){			
			return getTbJxshPage(page, size , this);
		}
		/** 根据查询条件取经销商 **/
		public @api TbJxsh get(){			
			return getTbJxsh(this);
		}
		/** 获取经销商数 **/
		public @api Long count(){			
			return getTbJxshCount(this);
		}
		/** 获取经销商表达式 **/
		public @api <T> T eval(String strEval){			
			return getTbJxshEval(strEval,this);
		}
		
		/** 获取经销商统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getTbJxshStats(this,sumKey,groupKey,dateType);
		}
		/** 获取经销商统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getTbJxshStats(this,sumKey,groupKey,-1);
		}
		
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateTbJxsh(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteTbJxsh(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		
			
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String tbjId="tbjId";
	 			
			
	 	
			
		/** 品牌  [Merchant]      **/
		public final static @type(Long.class)  String tbjBrand="tbjBrand";
	 			
			
	 	
			
		/** 经销商名称        **/
		public final static @type(String.class)  String tbjName="tbjName";
	 			
			
	 	
			
		/** 电话        **/
		public final static @type(String.class)  String tbjPhone="tbjPhone";
	 			
			
	 	
			
		/** 总收益        **/
		public final static @type(Double.class)  String tbjProfit="tbjProfit";
	 			
		/** and tbj_profit >= ? */
		public final static @type(Double.class) String tbjProfitMin="tbjProfitMin";
		/** and tbj_profit <= ? */
		public final static @type(Double.class) String tbjProfitMax="tbjProfitMax";
				
			
	 	
			
		/** 所在位置  [Region]      **/
		public final static @type(Long.class)  String tbjLocation="tbjLocation";
	 			
			
	 	
			
		/** 添加时间        **/
		public final static @type(Date.class)  String tbjAddTime="tbjAddTime";
	 			
	 	/** and tbj_add_time >= ? */
 		public final static @type(Date.class) String tbjAddTimeStart="tbjAddTimeStart";
 		/** and tbj_add_time <= ? */
 		public final static @type(Date.class) String tbjAddTimeEnd="tbjAddTimeEnd";
				
			
	 	
			
		/** 状态    0:无效 1:有效     **/
		public final static @type(Short.class)  String tbjStatus="tbjStatus";
	 			
			
	 	
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/** 对象的数据库字段描述 **/
	public static enum C{
		
		tbjId("tbj_id"),
		tbjBrand("tbj_brand"),
		tbjName("tbj_name"),
		tbjPhone("tbj_phone"),
		tbjProfit("tbj_profit"),
		tbjLocation("tbj_location"),
		tbjAddTime("tbj_add_time"),
		tbjStatus("tbj_status"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	
	/**
	* 获取经销商数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = TbJxsh.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = TbJxsh.getTbJxsh(params);
			else
				value = TbJxsh.getTbJxshList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  TbJxsh.where().tbjId(param).get();
		else if(!Utils.empty(param.toString()))
			value = TbJxsh.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		return toJSON(simple,0);
	}
	public Map toJSON(boolean simple,int step){
		Map map = new HashMap();
		map.put("id",this.getTbjId());
	
		Utils.fms(map,simple?"id":"tbjId",this.getTbjId(),this.getTbjId$());
		
			
 		
	
		Utils.fms(map,simple?"brand":"tbjBrand",this.getTbjBrand(),this.getTbjBrand$());
		
			
 		
	
		Utils.fms(map,simple?"name":"tbjName",this.getTbjName(),this.getTbjName$());
		
			
 		
	
		Utils.fms(map,simple?"phone":"tbjPhone",this.getTbjPhone(),this.getTbjPhone$());
		
			
 		
	
		Utils.fms(map,simple?"profit":"tbjProfit",this.getTbjProfit(),this.getTbjProfit$());
		
			
 		
	
		Utils.fms(map,simple?"location":"tbjLocation",this.getTbjLocation(),this.getTbjLocation$());
		
			
 		
	
		Utils.fms(map,simple?"addTime":"tbjAddTime",this.getTbjAddTime(),this.getTbjAddTime$());
		
		map.put("atime",this.getTbjAddTime$());map.put("ctime",this.getTbjAddTime$());
		
			
 		
	
		Utils.fms(map,simple?"status":"tbjStatus",this.getTbjStatus(),this.getTbjStatus$());
		
			
 		
	
		if(this.suffix!=null)map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
	
		map.put("tbjId",this.getTbjId());
 		
	
		map.put("tbjBrand",this.getTbjBrand());
 		
	
		map.put("tbjName",this.getTbjName());
 		
	
		map.put("tbjPhone",this.getTbjPhone());
 		
	
		map.put("tbjProfit",this.getTbjProfit());
 		
	
		map.put("tbjLocation",this.getTbjLocation());
 		
	
		map.put("tbjAddTime",this.getTbjAddTime());
 		
	
		map.put("tbjStatus",this.getTbjStatus());
 		
	
		map.put("suffix", this.suffix);
		
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static TbJxsh fromMap(Map map){
		TbJxsh tbJxsh = new TbJxsh();
	
		tbJxsh.tbjId = Utils.parseLong(map.get("tbjId"));
 		
	
		tbJxsh.tbjBrand = Utils.parseLong(map.get("tbjBrand"));
 		
	
		tbJxsh.tbjName = Utils.parseString(map.get("tbjName"));
 		
	
		tbJxsh.tbjPhone = Utils.parseString(map.get("tbjPhone"));
 		
	
		tbJxsh.tbjProfit = Utils.parseDouble(map.get("tbjProfit"));
 		
	
		tbJxsh.tbjLocation = Utils.parseLong(map.get("tbjLocation"));
 		
	
		tbJxsh.tbjAddTime = Utils.parseDate(map.get("tbjAddTime"));
 		
	
		tbJxsh.tbjStatus = Utils.parseShort(map.get("tbjStatus"));
 		
	
		return tbJxsh;
	}
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(TbJxsh old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	
	
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	
	public static String getIcon(){
		return "/images/icons/13929_administrator.png";
	}
	public static String getIconfont(){
		return "icon-kehu";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,TbJxsh.M params){
		if(params==null)params=new TbJxsh.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/business/jxsh.edit.html?";
		if(params.get("tbjId")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("tbjId"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/business/jxsh.html?1=1";
		
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		
		
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.tbjId(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(TbJxsh.ACT act,TbJxsh.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",TbJxsh.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(TbJxsh.ACT act,TbJxsh.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",TbJxsh.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.ITbJxshDao getTbJxshDao(){
		return Utils.getBean("tbJxshDao");
	};
	
}